import uiPanel from "./../../lib/UiPanel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class RowItem extends uiPanel {
	@property(cc.Label)
	text: cc.Label = null;

	@property(cc.Node)
	line: cc.Node = null;

	@property(cc.Node)
	buttonSp: cc.Node = null;

	@property(cc.Node)
	button: cc.Node = null;

	index = 0;


	//pagePath = null;
	parentUUID = null;

	onLoad() {

	}
	onEnable() { }

	onDisable() { }

	onDestroy() { }

	show() {
		this.node.active = true;
	}
	hide() {
		this.node.active = false;
	}

	//type:0(标题)，1（中间内容），2（最后一条）
	fill(index: number, type: number, width: number, text: string, color: string) {
		this.show();

		this.index = index;
		this.node.width = width;

		this.button.width = width;
		this.line.x = width / 2;
		if (type == 2) {
			this.line.active = false;
		} else {
			this.line.active = true;
		}

		var _head = text.substr(0, 1);
		if (_head == "@") {
			this.button.active = true;
			this.text.node.active = false;
			//	this.pagePath = text.substr(1, text.length - 1);
			this.parentUUID = text.substr(1, text.length - 1);
		} else {
			this.button.active = false;
			this.text.node.active = true;
		}
		this.text.string = text;
		this.text.node.color = new cc.Color().fromHEX(color || "#000000");
	}

	onclickButton() {
		cc.vv.audioUtil.playSound("Hall/sound/button_onclicked");
		//cc.vv.UIMgr.open(this.pagePath, null, null);

		cc.vv.eventCustom.emit("rowItemChoose", { uuid: this.parentUUID, index: this.index });

	}





}
